package tag

import org.apache.spark.sql.Row

object DeviceTags extends Tags {
  override def makeTags(args: Any*): List[(String, Int)] = {
    //获取参数row
    val row = args(0).asInstanceOf[Row]
    //创建list
    var list = List[(String,Int)]()
    val client = row.getAs[Int]("client")
    val networkmannername = row.getAs[String]("networkmannername")
    val ispname = row.getAs[String]("ispname")
    if (client == 1) {
      list :+= ("D00010001", 1)
    } else if (client == 2) {
      list :+= ("D00010002", 1)
    } else if (client == 3) {
      list :+= ("D00010003", 1)
    } else {
      list :+= ("D00010004", 1)
    }
    networkmannername.toUpperCase match {
      case "WIFI" => list :+= ("D00020001", 1)
      case "4G" => list :+= ("D00020002", 1)
      case "3G" => list :+= ("D00020003", 1)
      case "2G" => list :+= ("D00020004", 1)
      case _ => list :+= ("D00020005", 1)
    }

    ispname match {
      case "移动" => list :+= ("D00030001", 1)
      case "联通" => list :+= ("D00030002", 1)
      case "电信" => list :+= ("D00030003", 1)
      case _ => list :+= ("D00030004", 1)
    }

    list

  }
}
